home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0037_TWEAKED.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  4KB  |  105 lines

  1. {
  2.  Hi, would anyone like to tell me how to get the tweaked video
  3.  mode With 4 pages to work With because I'm tired of the 16 color
  4.  2 page demos I'm making.
  5.  
  6. Sure, here's an adaptation of some code from Dr. Dobbs magazine on Mode-X.
  7. I've only posted the routine to set the VGA to 360x240x256 With 3 pages of
  8. Graphics.  Only 3 pages since the increase in resolution Uses more RAM.
  9. }
  10.  
  11. Procedure InitVGA360x240;
  12.  
  13. Const
  14.   GC_inDEX    = $03CE;    { VGA Graphics Controller }
  15.   SC_inDEX    = $03C4;    { VGA Sequence controller }
  16.   CrtC_inDEX  = $03D4;    { VGA Crt Controller      }
  17.   MISC_OUTPUT = $03C2;    { VGA Misc Register       }
  18.   MAP_MASK    = $02;      { Map Register #          }
  19.   READ_MAP    = $04;      { Read Map Register #     }
  20.  
  21.   VMODE_DATA  : Array[1..17] of Word =
  22.                    ($6B00,    { Horizontal total          }
  23.                     $5901,    { Horizontal displayed      }
  24.                     $5A02,    { Start horizontal blanking }
  25.                     $8E03,    { end horizontal blanking   }
  26.                     $5E04,    { Start H sync.             }
  27.                     $8A05,    { end H sync.               }
  28.                     $0D06,    { Vertical total            }
  29.                     $3E07,    { Overflow                  }
  30.                     $4109,    { Cell height               }
  31.                     $EA10,    { V sync. start             }
  32.                     $AC11,    { V sync. end/Prot CR0 CR7  }
  33.                     $DF12,    { Vertical displayed        }
  34.                     $2D13,    { offset                    }
  35.                     $0014,    { DWord mode off            }
  36.                     $E715,    { V Blank start             }
  37.                     $0616,    { V Blank end               }
  38.                     $E317);   { Turn on Byte mode         }
  39.  
  40. begin
  41.   Asm
  42.    mov   ax, $13
  43.    int   $10
  44.  
  45.    mov   dx, SC_inDEX           { Sequencer Register }
  46.    mov   ax, $0604              { Disable Chain 4 Mode }
  47.    out   dx, ax
  48.  
  49.    mov   ax, $0100              { (A)synchronous Reset }
  50.    out   dx, ax
  51.  
  52.    mov   dx, MISC_OUTPUT        { VGA Misc Register }
  53.    mov   al, $E7                { Use 28Mhz Clock & 60Hz }
  54.    out   dx, al
  55.  
  56.    mov   dx, SC_inDEX           { Sequencer Register }
  57.    mov   ax, $0300              { Restart Sequencer }
  58.    out   dx, ax
  59.  
  60.    {
  61.      Diasable Write protect For CrtC Registers 0-7, since we are
  62.      about to change the horizontal & vertical timing settings.
  63.    }
  64.    mov   dx, CrtC_inDEX         { VGA CrtC Registers }
  65.    mov   al, $11                { CrtC register 11h }
  66.    out   dx, al                 { Load current value }
  67.    inc   dx                     { Point to data }
  68.    in    al, dx                 { Get CrtC register 11h }
  69.    and   al, $7F                { Mask out Write protect }
  70.    out   dx, al                 { and send it back }
  71.  
  72.    { Send CrtC data in VMODE_DATA Array to the CrtC. }
  73.    mov   dx, CrtC_inDEX         { VGA CrtC Registers }
  74.    cld                          { Forward block load }
  75.    mov   si, offset VMODE_DATA  { Get parameter data }
  76.    mov   cx, 17                 { Number of entries in block }
  77.  
  78.    @@1:
  79.      mov   ax, ds:[si]      { Get next parameter value }
  80.      inc   si               { Advance to next Word }
  81.      inc   si
  82.      out   dx, ax           { Output next value }
  83.      loop  @@1              { Process next value }
  84.  
  85.    { Clear all VGA memory to black. }
  86.    mov   dx, SC_inDEX     { Select all planes }
  87.    mov   ax, $0F02
  88.    out   dx, ax
  89.  
  90.    mov   ax, VGA_SEG      { Point to VGA memory }
  91.    mov   es, ax
  92.    mov   di, 0
  93.  
  94.    xor   ax, ax           { clear 256K }
  95.    mov   cx, $8000        { 32K * 2 * 4 planes }
  96.    rep   stosw
  97.   end;
  98. end;
  99. {
  100. That's about it.  The video memory in this mode is organised a bit differently
  101. than CGA/HERC.  It is a lot like the 16 color modes you're probably used to, in
  102. that you must go through the EGA/VGA Registers to access the memory, by setting
  103. MAP MASK & PLANE SELECT, etc.
  104. }
  105.